﻿namespace ProblemsSet
{
    public class Problem_56 : BaseProblem
    {
        public override object GetResult()
        {
            const int mx = 100;

            long res = 0;
            for (var a = 2; a < mx; a++ )
            {
                for (var b = 2; b < mx; b++)
                {
                    var tmp = a.ToString();
                    tmp = tmp.TrimEnd(new char[1] { '0' });
                    long rs = 0;
                    for (var i = 2; i <= b; i++)
                    {
                        tmp = MathLogic.MultipleString(tmp, a, out rs);
                        tmp = tmp.TrimEnd(new char[1] {'0'});
                    }
                    if (rs > res) res = rs;
                }
            }
            return res;
        }

        public override string Problem
        {
            get
            {
                return @"A googol (10100) is a massive number: one followed by one-hundred zeros; 100100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits in each number is only 1.

Considering natural numbers of the form, ab, where a, b  100, what is the maximum digital sum?";
            }
        }

        public override bool IsSolved
        {
            get
            {
                return true;
            }
        }

        public override object Answer
        {
            get
            {
                return 972;
            }
        }

    }
}
